﻿using NoteHelper.IBusiness;
using NoteHelper.Utils;
using System;
using Unity;

namespace NoteHelper
{
    public partial class NavigateForm : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        private IProjectFormManager projectFormManager;
        public NavigateForm()
        {
            InitializeComponent();

            var container = UnityHelper.GetContainer();
            projectFormManager = container.Resolve<IProjectFormManager>();
            searchbar1.ExecuteSearch += ExecuteCommand;
        }

        private void ExecuteCommand(string txt)
        {
            var lst = projectFormManager.GetList(txt);
            if (lst.Count == 0)
            {
                return;
            }

            string className = lst[0].FullName;
            DockHandler.ShowPanel(className);
        }
    }
}
